#pragma once

#include "includeBase.h"

#include "pcl/PclInclude.h"

#include "core/AppContext.h"

class PointCloudWidget : public QWidget
{
protected:
    Q_OBJECT

public:
    PointCloudWidget(QWidget* parent = nullptr);

    static PointCloudWidget& get() { return *that_; }

public:
    pcl::visualization::PCLVisualizer::Ptr viewer() { return viewer_; }
    void updateUI();

private: // methods
    void setupUi();
    void setupMain();
    void setupToobar();
    void setupCloud();
    void setupView();

    void openPcd(const QString& pcdPath);

private slots:
    void onActionClearClouds();
    void onActionOpen();
    void onActionNormalEstimation();

private:
    void addLine(const vector<vector<double>>& linePoints, const string& label);

private: // Fields
    static PointCloudWidget* that_;
    QGridLayout* layoutMain;
    QVTKOpenGLNativeWidget* qvtkWidget_;
    pcl::visualization::PCLVisualizer::Ptr viewer_;
    PointCloudT::Ptr cloud_;
};
